let vm = null;
import table from '@/components/dt/table/render.js'

function columnField() {
  let columns2 = {}
  columns2 = {
    orgDivisionName: {
      field: 'orgDivisionName',
      title: '事业部',
      minWidth: 140,
    },
    orgCompanyName: {
      field: 'orgCompanyName',
      title: '分公司',
      minWidth: 140,
    },
    orgOfficeName: {
      title: '事业处',
      field: 'orgOfficeName',
      minWidth: 140,
    },

    housesName: {
      title: '案场名称',
      field: 'housesName',
      minWidth: 160,
    },

    statusDesc: {
      title: '案场状态',
      field: 'statusDesc',
      minWidth: 120,
    },
    enterDate: {
      title: '项目进场日期',
      field: 'enterDate',
      minWidth: 180,
      cell: {
        value: (row) => row.enterDate ? vm.$tool.dateFtt('yyyy/MM/dd', row
          .enterDate) : '',
        text: {}
      }
    },
    expectedOpenTime: {
      title: '预计开盘(含加推)日期',
      field: 'expectedOpenTime',
      minWidth: 180,
      cell: {
        value: (row) => row.expectedOpenTime ? vm.$tool.dateFtt('yyyy/MM/dd', row
          .expectedOpenTime) : '',
        text: {}
      }
    },
    realityWithdrawalDate: {
      title: '实际撤场日期(停止销售，人员撤场)',
      field: 'realityWithdrawalDate',
      minWidth: 260,
      cell: {
        value: (row) => row.realityWithdrawalDate ? vm.$tool.dateFtt('yyyy/MM/dd', row
          .realityWithdrawalDate) : '',
        text: {}
      }
    },
    withdrawalReason: {
      title: '撤场原因',
      field: 'withdrawalReason',
      minWidth: 160,
    },
    withdrawalExplain: {
      title: '撤场原因说明',
      field: 'withdrawalExplain',
      minWidth: 220,
    },
    productName: {
      title: '产品名称',
      field: 'productName',
      minWidth: 160,
    },
    productType: {
      title: '产品类型',
      field: 'productType',
      minWidth: 120,
      cell: {
        text: {
          type: 'dict',
          key: 'productType'
        }
      }
    },

    coopMode: {
      title: '合作模式',
      field: 'coopMode',
      minWidth: 160,
      cell: {
        text: {
          type: 'dict',
          key: 'cooperationModeAttrSort'
        }
      }
    },
    sellMode: {
      title: '代理方式',
      field: 'sellMode',
      minWidth: 160,
      cell: {
        text: {
          type: 'dict',
          key: 'salesModel'
        }
      }
    },
    proxyFee: {
      title: '基础代理费',
      field: 'proxyFee',
      minWidth: 160,
    },
    isJumpCommission: {
      title: '是否跳帕',
      field: 'isJumpCommission',
      minWidth: 160,
      cell: {
        value: (row) => row.isJumpCommission != null ? row.isJumpCommission == '1' ? '是' :
          '否' : '-',
        text: {}
      }
    },
    jumpPaInterval: {
      title: '跳帕区间',
      field: 'jumpPaInterval',
      minWidth: 160,
    },
    availableRoom: {
      title: '截止月底整盘剩余可售货量(套数)',
      field: 'availableRoom',
      minWidth: 240,
      cell: {
        text: {
          type: 'number',
          fixed: 0
        }
      }
    },
    availableRoomAmount: {
      title: '截止月底整盘剩余可售货量(元)',
      field: 'availableRoomAmount',
      minWidth: 240,
      cell: {
        text: {
          type: 'number',
          fixed: 0
        }
      }
    },

    generationCompany: {
      field: 'generationCompany',
      title: '联代公司简称',
      minWidth: 180,
    },
    projectPowerConnectionRules: {
      field: 'projectPowerConnectionRules',
      title: '项目接电规则',
      minWidth: 160,
    },
    projectReceptionRules: {
      field: 'projectReceptionRules',
      title: '项目接待规则',
      minWidth: 160,
    },
    isSecurityFund: {
      field: 'isSecurityFund',
      title: '是否有保证金',
      minWidth: 110,
      cell: {
        value: (row) => row.isSecurityFund != null ? row.isSecurityFund == '1' ? '是' : '否' :
          '-',
        text: {}
      }
    },
    securityFundMoney: {
      field: 'securityFundMoney',
      title: '保证金金额(元)',
      minWidth: 160,
      cell: {
        text: {
          type: 'number',
          fixed: 0
        }
      }
    },
    wePay: {
      field: 'wePay',
      title: '我司付费渠道',
      minWidth: 160,
    },
    partyAPay: {
      title: '甲方付费渠道',
      field: 'partyAPay',
      minWidth: 160,
    },
    developerAbbreviation: {
      title: '开发商简称',
      field: 'developerAbbreviation',
      minWidth: 180,
    },
    province: {
      title: '城市(省-市级)',
      field: 'province',
      minWidth: 120,
    },
    city: {
      title: '城(地级)',
      field: 'city',
      minWidth: 120,
    },
    area: {
      title: '城市(县级)',
      field: 'area',
      minWidth: 120,
    },
    plate: {
      title: '区域(区/镇)',
      field: 'plate',
      minWidth: 120,
    },
    address: {
      title: '售楼处地址',
      field: 'address',
      minWidth: 180,
    },
    salesOfficePhone: {
      title: '售楼处电话',
      field: 'salesOfficePhone',
      minWidth: 160,
    },
    chairman: {
      title: '主委信息',
      field: 'chairman',
      minWidth: 220,
    },
    commissioner: {
      title: '专案信息',
      field: 'commissioner',
      minWidth: 220,
    },
    number: {
      title: '项目实际人数',
      field: 'number',
      minWidth: 120,
    },
    tasksDesc: {
      title: '考核项',
      field: 'tasksDesc',
      minWidth: 120,
      slots: {
        default: (params, h) => {
          return params.row.tasksDesc ?
            table.cell.btn(vm, h, {
              title: `${params.row.tasksDesc}`,
              event: 'getSOPInfo',
              data: params.row
            }) : '-'
        }
      }
    },
    deductPointsDesc: {
      title: '扣分项',
      field: 'deductPointsDesc',
      minWidth: 120,
      slots: {
        default: (params, h) => {
          return params.row.deductPointsDesc ?
            table.cell.btn(vm, h, {
              title: `${params.row.deductPointsDesc}`,
              event: 'getPointsSop',
              data: params.row
            }) : '-'
        }
      }
    },
    mainDataCode: {
      title: '成本中心',
      field: 'mainDataCode',
      minWidth: 260,
    }
  }
  return columns2
}

function columns(head) {
  let fields = columnField(),
    data = []
  for (let item of head) {
    if (fields[item.fieldKey]) {
      data.push(fields[item.fieldKey])
    }
  }
  return data
}

function options(_this, head) {
  vm = _this
  return [
    ...columns(head),
  ]
}
export default {
  options,
}